home *** CD-ROM | disk | FTP | other *** search
- unit uEditProfile;
-
- {
- *******************************************************************************
- * Descriptions: Profile Dialog placeholder
- * $Source: /cvsroot/fma/fma/uEditProfile.pas,v $
- * $Locker: $
- *
- * Todo:
- *
- * Change Log:
- * $Log: uEditProfile.pas,v $
- * Revision 1.11 2004/06/17 13:16:54 z_stoichev
- * Merged uEditProfile and uEditProfileDlg
- *
- * Revision 1.6 2004/05/19 18:34:15 z_stoichev
- * Build 0.1.0.35c
- *
- * Revision 1.5 2003/11/28 09:38:07 z_stoichev
- * Merged with branch-release-1-1 (Fma 0.10.28c)
- *
- * Revision 1.4.2.1 2003/10/27 07:22:54 z_stoichev
- * Build 0.1.0 RC1 Initial Checkin.
- *
- * Revision 1.4 2003/10/24 12:33:21 z_stoichev
- * Make size independent of child frame's size.
- * Fixed Win XP theme issue.
- *
- * Revision 1.3 2003/01/30 04:15:57 warren00
- * Updated with header comments
- *
- *
- *******************************************************************************
- }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, TntStdCtrls, ComCtrls;
-
- type
- TfrmEditProfile = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- lblName: TLabel;
- Label2: TLabel;
- Edit1: TTntEdit;
- GroupBox5: TGroupBox;
- trkBarData: TTrackBar;
- chkIncData: TCheckBox;
- GroupBox4: TGroupBox;
- trkBarFax: TTrackBar;
- chkIncFax: TCheckBox;
- GroupBox3: TGroupBox;
- trkBarL2: TTrackBar;
- chkIncL2: TCheckBox;
- GroupBox2: TGroupBox;
- trkBarL1: TTrackBar;
- chkIncL1: TCheckBox;
- chkSIL: TCheckBox;
- TabSheet2: TTabSheet;
- Label1: TLabel;
- lblNameCopy: TTntLabel;
- grpAns: TRadioGroup;
- grpFont: TGroupBox;
- fsRadioButton1: TRadioButton;
- fsRadioButton2: TRadioButton;
- fsRadioButton3: TRadioButton;
- grpSMS: TRadioGroup;
- grpVib: TRadioGroup;
- grpLight: TRadioGroup;
- grpKS: TGroupBox;
- ksRadioButton1: TRadioButton;
- ksRadioButton2: TRadioButton;
- ksRadioButton3: TRadioButton;
- btnOk: TButton;
- btnCancel: TButton;
- btnApply: TButton;
- procedure FormShow(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Edit1Change(Sender: TObject);
- procedure btnApplyClick(Sender: TObject);
- procedure OnMod(Sender: TObject);
- procedure btnOkClick(Sender: TObject);
- private
- { Private declarations }
- OldName: string;
- Oldindex: string;
-
- MMIFontSupport: boolean;
- function getFontMode: integer;
- function getKeySound: integer;
-
- procedure ERIL;
- procedure ESIL;
- procedure EFOS;
- procedure ESBL;
- procedure CVIB;
- procedure ESAM;
- procedure ESKS;
- procedure ESMA;
- procedure EAPS;
- procedure EAPS_N;
-
- procedure InitSetting;
- procedure SendSetting;
- public
- { Public declarations }
- end;
-
- var
- frmEditProfile: TfrmEditProfile;
-
- implementation
-
- uses Unit1, uStatusDlg;
-
- {$R *.dfm}
-
- procedure TfrmEditProfile.FormCreate(Sender: TObject);
- begin
- {$IFNDEF VER150}
- Form1.ThemeManager1.CollectForms(Self);
- {$ENDIF}
- end;
-
- procedure TfrmEditProfile.FormShow(Sender: TObject);
- begin
- PageControl1.ActivePageIndex := 0;
- btnOk.SetFocus;
- InitSetting;
- end;
-
- procedure TfrmEditProfile.InitSetting;
- begin
- with ShowStatusDlg('Getting setting profile...') do
- try
- Form1.Status('Getting setting profile...');
- EAPS();
- EAPS_N();
- ESAM();
- ESIL();
- ERIL();
- EFOS();
- ESBL();
- CVIB();
- ESKS();
- ESMA();
- Form1.Status('');
- finally
- Free;
- btnApply.Enabled := False;
- end;
- end;
-
- procedure TfrmEditProfile.ERIL;
- var
- i: Integer;
- str: String;
- strlst: TStringlist;
- value : Integer;
- begin
- try
- Form1.TxAndWait('AT*ERIL?');
-
- strlst := Tstringlist.Create();
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ERIL', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- str := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- strlst.DelimitedText := str;
- value := strtoint(strlst[0]);
- if strlst[1] = '1' then
- begin
- trkBarL1.Position := value mod 128;
- if value > 128 then
- chkincl1.Checked := true
- else
- chkincl1.Checked := false
- end;
- if strlst[1] = '2' then
- begin
- trkBarL2.Position := value mod 128;
- if value > 128 then
- chkincl2.Checked := true
- else
- chkincl2.Checked := false
- end;
- if strlst[1] = '3' then
- begin
- trkBarfax.Position := value mod 128;
- if value > 128 then
- chkincfax.Checked := true
- else
- chkincfax.Checked := false
- end;
- if strlst[1] = '4' then
- begin
- trkBardata.Position := value mod 128;
- if value > 128 then
- chkincdata.Checked := true
- else
- chkincdata.Checked := false
- end;
- end;
- end;
- except
- Form1.Debug('Error getting Sound volume Setting');
- end;
-
- end;
-
- procedure TfrmEditProfile.ESIL;
- var
- i: Integer;
- str: String;
- begin
- try
- Form1.TxAndWait('AT*ESIL?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESIL', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- str := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- if str = '0' then
- chksil.Checked := false
- else
- chksil.Checked := true;
- end;
- end;
- except
- Form1.Debug('Error getting Silent Setting');
- end;
- end;
-
- procedure TfrmEditProfile.EFOS;
- var
- i,j: Integer;
- s: string;
- value: Integer;
- begin
- try
- try
- { Read available Font modes }
- Form1.TxAndWait('AT*EFOS=?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*EFOS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- { format is "(X-Y)" }
- s := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- j := Pos('-',s);
- for j := StrToInt(s[j-1]) to StrToInt(s[j+1]) do begin
- case j of
- 1: fsRadioButton1.Enabled := True;
- 2: fsRadioButton2.Enabled := True;
- 3: fsRadioButton3.Enabled := True;
- end;
- end;
- end;
- end;
- MMIFontSupport := True;
- except
- MMIFontSupport := False;
- Form1.Debug('MMI Font Setting not supported');
- Abort;
- end;
- Form1.TxAndWait('AT*EFOS?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*EFOS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i])));
- case value of
- 1: fsRadioButton1.Checked := True;
- 2: fsRadioButton2.Checked := True;
- 3: fsRadioButton3.Checked := True;
- end;
- end;
- end;
- except
- { Strange that "AT*EFOS=?" works, but "AT*EFOS?" fails on T610 }
- fsRadioButton1.Enabled := False;
- fsRadioButton2.Enabled := False;
- fsRadioButton3.Enabled := False;
- MMIFontSupport := False;
- Form1.Debug('Error getting Font Setting');
- end;
- end;
-
- procedure TfrmEditProfile.ESBL;
- var
- i: Integer;
- value: Integer;
- begin
- try
- Form1.TxAndWait('AT*ESBL?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESBL: 0', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 10, length(Form1.FRxBuffer.Strings[i])));
- grpLight.ItemIndex := value;
- end;
- end;
- except
- Form1.Debug('Error getting Backlight Setting');
- end;
-
- end;
-
- procedure TfrmEditProfile.CVIB;
- var
- i: Integer;
- value: Integer;
- begin
- try
- Form1.TxAndWait('AT+CVIB?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('+CVIB', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i])));
- case value of
- 16: grpVib.ItemIndex := 2;
- else
- grpVib.ItemIndex := value;
- end;
- end;
- end;
- except
- Form1.Debug('Error getting Vibration Setting');
- end;
- end;
-
- procedure TfrmEditProfile.ESAM;
- var
- i: Integer;
- value: Integer;
- begin
- try
- Form1.TxAndWait('AT*ESAM?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESAM', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i])));
- grpAns.ItemIndex := value;
- end;
- end;
- except
- Form1.Debug('Error getting Answer Setting');
- end;
- end;
-
- procedure TfrmEditProfile.ESKS;
- var
- i,j: Integer;
- s: string;
- value: Integer;
- begin
- try
- { Read available Key Sound modes }
- Form1.TxAndWait('AT*ESKS=?');
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESKS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- { format is "(X-Y)" }
- s := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- j := Pos('-',s);
- for j := StrToInt(s[j-1]) to StrToInt(s[j+1]) do begin
- case j of
- 0: ksRadioButton1.Enabled := True;
- 1: ksRadioButton2.Enabled := True;
- 2: ksRadioButton3.Enabled := True;
- end;
- end;
- end;
- end;
- Form1.TxAndWait('AT*ESKS?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESKS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i])));
- case value of
- 0: ksRadioButton1.Checked := True;
- 1: ksRadioButton2.Checked := True;
- 2: ksRadioButton3.Checked := True;
- end;
- end;
- end;
- except
- Form1.Debug('Error getting Keys sound Setting');
- end;
- end;
-
- procedure TfrmEditProfile.ESMA;
- var
- i: Integer;
- value: Integer;
- begin
- try
- Form1.TxAndWait('AT*ESMA?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*ESMA', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- value := strtoint(Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i])));
- grpSMS.ItemIndex := value;
- end;
- end;
- except
- Form1.Debug('Error getting Message sound Setting');
- end;
- end;
-
- procedure TfrmEditProfile.SendSetting;
- var value:Integer;
- begin
- with ShowStatusDlg('Sending setting profile...') do
- try
- //send answer
- Form1.TxAndWait('AT*ESAM=' + inttostr(grpAns.ItemIndex));
- //send message sound
- Form1.TxAndWait('AT*ESMA=' + inttostr(grpSMS.ItemIndex));
- //send backlight
- Form1.TxAndWait('AT*ESBL=0,' + inttostr(grpLight.ItemIndex));
- //send font
- if MMIFontSupport then
- Form1.TxAndWait('AT*EFOS=' + inttostr(getFontMode));
- //Form1.TxAndWait('AT*EFOS=' + inttostr(grpFont.ItemIndex + 1));
- //send vibration
- case grpVib.ItemIndex of
- 2: Form1.TxAndWait('AT+CVIB= 16');
- else
- Form1.TxAndWait('AT+CVIB=' + inttostr(grpVib.ItemIndex));
- end;
- //send keys sound
- Form1.TxAndWait('AT*ESKS=' + inttostr(getKeySound));
- //send silent
- if chkSil.Checked then
- Form1.TxAndWait('AT*ESIL=1')
- else
- Form1.TxAndWait('AT*ESIL=0');
- //send volume sound L1
- value := trkBarL1.Position;
- if chkIncL1.Checked then
- if value = 0 then
- value := 129
- else
- value := value + 128;
- Form1.TxAndWait('AT*ERIL=' + inttostr(value) + ',1');
- //send volume sound L2
- value := trkBarL2.Position;
- if chkIncL2.Checked then
- if value = 0 then
- value := 129
- else
- value := value + 128;
- Form1.TxAndWait('AT*ERIL=' + inttostr(value) + ',2');
- //send volume sound Fax
- value := trkBarFax.Position;
- if chkIncFax.Checked then
- if value = 0 then
- value := 129
- else
- value := value + 128;
- Form1.TxAndWait('AT*ERIL=' + inttostr(value) + ',3');
- //send volume sound Data
- value := trkBarData.Position;
- if chkIncData.Checked then
- if value = 0 then
- value := 129
- else
- value := value + 128;
- Form1.TxAndWait('AT*ERIL=' + inttostr(value) + ',4');
- //send name
- if Oldname <> edit1.Text then
- try
- if Form1.FUseUTF8 then
- Form1.TxAndWait('AT*EAPN="' + UTF8Encode(Edit1.Text) + '"')
- else
- Form1.TxAndWait('AT*EAPN="' + Edit1.Text + '"');
- except
- edit1.Text := OldName;
- lblNameCopy.Caption := OldName;
- btnApply.Enabled := False; // we're done already sinte this is the last setting
- Form1.Status('Rename aborted');
- MessageBeep(MB_ICONASTERISK);
- MessageDlg('This profile name is hardcoded in phone and can not be renamed',
- mtInformation,[mbOk],0);
- Abort;
- end
- finally
- Free;
- end;
- end;
-
- procedure TfrmEditProfile.EAPS;
- var
- i: Integer;
- value: Integer;
- str: String;
- strlst: TStringlist;
- begin
- try
- strlst := TStringlist.Create;
-
- Form1.TxAndWait('AT*EAPS=?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*EAPS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- str := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- strlst.DelimitedText := str;
- value := strtoint(strlst[1]);
- edit1.MaxLength := value;
- end;
- end;
- except
- Form1.Debug('Error getting Profile name Setting');
- end;
- end;
-
- procedure TfrmEditProfile.EAPS_N;
- var
- i: Integer;
- str: WideString;
- strlst: TStringlist;
- begin
- try
- strlst := TStringlist.Create;
-
- Form1.TxAndWait('AT*EAPS?');
-
- for i := 0 to Form1.FRxBuffer.Count - 2 do begin
- if pos('*EAPS', Form1.FRxBuffer.Strings[i]) = 1 then
- begin
- str := Copy(Form1.FRxBuffer.Strings[i], 8, length(Form1.FRxBuffer.Strings[i]));
- if Form1.FUseUTF8 then str := UTF8Decode(str);
- strlst.DelimitedText := str;
- Oldindex := strlst[0];
- OldName := strlst[1];
- edit1.Text := OldName;
- Edit1Change(nil);
- end;
- end;
- except
- Form1.Debug('Error getting Active Profile name Setting');
- end;
- end;
-
- function TfrmEditProfile.getFontMode: integer;
- begin
- Result := 1;
- if fsRadioButton2.Checked then
- Result := 2
- else if fsRadioButton3.Checked then
- Result := 3;
- end;
-
- function TfrmEditProfile.getKeySound: integer;
- begin
- Result := 0;
- if ksRadioButton2.Checked then
- Result := 1
- else if ksRadioButton3.Checked then
- Result := 2;
- end;
-
- procedure TfrmEditProfile.Edit1Change(Sender: TObject);
- begin
- lblNameCopy.Caption := Edit1.Text;
- btnApply.Enabled := True;
- end;
-
- procedure TfrmEditProfile.OnMod(Sender: TObject);
- begin
- btnApply.Enabled := True;
- end;
-
- procedure TfrmEditProfile.btnApplyClick(Sender: TObject);
- begin
- Form1.Status('Sending setting profile...');
- SendSetting;
- if Oldname <> edit1.Text then
- Form1.InitProfile();
- Form1.Status('');
- btnApply.Enabled := False;
- end;
-
- procedure TfrmEditProfile.btnOkClick(Sender: TObject);
- begin
- if btnApply.Enabled then btnApply.Click;
- ModalResult := mrOk;
- end;
-
- end.
-